home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 03 / 7 / DISK0378.ZIP / FSEDIT.DOC < prev    next >
Text File  |  1983-04-10  |  10KB  |  168 lines

  1. From: Jan. 83 issue of Microcomputing
  2. Modified by: Terry G. Bailey
  3.  
  4.         Full Screen Editor
  5.  
  6. Following is a copy of the article describing this program by D. E. Cortesi
  7.  
  8.         IBM's MVP  (Most Valuable Program)
  9.  
  10.    The most important piece of software in any computer system, for me,
  11. is its editor.
  12.    The editor is used for just about everthing: source programs, memos,
  13. business letters, batch command files, articles, datafiles...Everything
  14. that goes onto a disk gets there throught the editor program, or descends
  15. from something that did.
  16.    When I was loaned an IBM Personal Computer, I found that it lacked an
  17. editor.  It has Edlin, but I don't find that program an acceptable tool.
  18. I've been using full-screen editors for some years now, so I find it difficult
  19. to go back to a line-oriented editor - especially one as rudimentary as
  20. Edlin.
  21.    So there the machine sat, waiting for me to give it something to do.  But
  22. what I needed was some kind of stop-gap - an editor that I could tolerate
  23. until a professional product becomes available.
  24.    My solution was to write a stopgap editor in Basic.
  25.    The resulting program is interesting in several ways.  It's an example
  26. of how much you can accomplish in IBM's Basic, and of how you can use the
  27. Basic language in a structured style of programming.  And it's a scale 
  28. model of a full-screen editor, so it can serve as a test bed for ideas
  29. that you might have on how an editor should work.
  30.  
  31. PROGRAM OBJECTIVES.
  32.    The Stopgap Editor was an unusual programming project.  It was the first
  33. time I'd written a program with the intention of using it heavily for a short
  34. time and then throwing it away.
  35.    The first requirement was that it had to go together quickly; that dictated
  36. a clean, simple design using straightforward techniques.  The second requirement
  37. was that it have adequate function from the outset, because I was determined
  38. that there would be no second version of the program.
  39.    The program's speed of response would not be important, although it did
  40. have to accept input at my normal typing rate.  It wouldn't need to handle 
  41. large files; by the time I needed to edit large files, there would be a good
  42. editor on the market.
  43.    With these factors in mind, I sketched the parameters of the program.  It
  44. would keep a file of a couple hundred lines in storage as an array of strings.
  45. Lines would be no longer than the screen was wide.  In fact, for simplicity
  46. of coding, no line would be shorter than the screen width either.
  47.    It would present the file on the screen 24 lines at a time.  The user 
  48. would be able to move the cursor to insert, delete or type over characters.
  49. The special keypad functions of the PC keyboard would be supported to move
  50. the cursor over the screen and the screen over the file.  There would be
  51. control key signals to delete and insert lines and to move to the head and
  52. foot of the file.
  53.    The only disk I/O that would be required would be the ability to save the
  54. working file on disk and to load another file from disk.  Since there would
  55. never be a great amount of data at risk, error-checking and reporting would
  56. be minimal.
  57.    These were the objectives, let's look at the program that resulted.
  58.  
  59. USING STOPGAP.
  60.    The Stopgap Editor is loaded and executed like any other program in Basic.
  61. Shortly after starting, it presents you with a clear screen.
  62.    The screen now becomes the electronic equivalent of a roll of paper.  
  63. Each screen line corresponds to a line of characters in a disk file.  Move
  64. the cursor around with the up-,down-,left- and right-arrow keys and type
  65. anywhere you like.
  66.    The enter key moves the cursor to the left margin and down one line-
  67. without putting any data in the file.  The tab key moves the cursor to the
  68. next tab stop.  It doesn't put any data in the file either.
  69.    The end key moves the cursor to the right side of the screen.  The home
  70. key does one of three things, depending on where the cursor is when you
  71. press it.  If the cursor is away from the left margin, the home key moves it
  72. back to the left margin.  If the cursor is at the left margin but not on the
  73. top line, then the home key moves it to the top line.  If the cursor is in
  74. the top left corner, the home key moves it to the bottom left corner.  With
  75. a few presses of the home and end keys, you can move to any corner of the
  76. screen.  (I took this idea from the Magic Wand editor for CP/M.)
  77.    Type some characters on the screen.  Move the cursor into the middle of
  78. a word and press the insert key.  The cursor becomes double, framing the
  79. current character.  (On the top line of the screen, the upper half of the
  80. cursor is invisible.)
  81.    Now, each character you type will be inserted ahead of the current character.
  82. If the line is full, one character will be lost from the right end for each one
  83. inserted.  Pressing any key except a printable character will end insert mode.
  84.    You'll find that the backspace key erases the current character and moves 
  85. cursor to the left.  Press the delete key and the current character disappears
  86. while the rest of the line shifts to the left to fill in and the cursor stays
  87. in place.
  88.    If you keep inserting or deleting for about 50 characters, the screen 
  89. seems to go dead.  After a pause of about ten seconds, though, the system comes
  90. to life again.  This is a peculiarity of all Microsoft Basic interpreters.
  91.    The program has been doing several operations on character strings for
  92. every inserted or deleted character, and the Basic interpreter has filled up
  93. its working storage with garbage character strings.  It stops to tidy up - 
  94. and when Basic stops, everything stops.  When spring cleaning is over, work
  95. resumes.
  96.  
  97. PAGING THROUGH THE FILE
  98.    On every line of your file, type a few characters and hit the enter key.
  99. When you reach the bottom of the screen, keep going.  The topmost lines scroll
  100. out of sight.
  101.    Keep on typing for a while, then press the "PgUp" key on the keypad.  The 
  102. editor moves back 23 lines, or to the top of the file.  Note that the cursor
  103. stays where it was on the screen.  Press the "PgDn" key; the editor moves
  104. forward 23 lines, or to the bottom of the file if that comes first.
  105.    Now try pressing the "Ctrl" and "A" together.  That makes the editor move
  106. the screen back to the top line of the file.  Pressing "Ctrl" and "Z" causes
  107. it to move to the last line used.  This is how you move about in a larger file.
  108. Use control-A to get to the top of the file and then use the page-down key, or
  109. use control-Z to move to the end and then page up.
  110.    Go to the end of the file with control-Z, then move the cursor to the top
  111. of the screen with the home key.  Now press the up-arrow key.  The editor
  112. slides the screen up the file 23 lines and moves the cursor down 23 lines,
  113. so that it is still on the line you were looking at.
  114.  
  115. LINE INSERTION AND DELETION
  116.    Hitting contol-D causes the editor to delete the entire line on which the
  117. cursor rests.  It redraws the whole screen afterward, so deletion is a fairly
  118. slow process.
  119.    Inserting lines is a bit faster.  When you press control-O, the editor
  120. splits the file just above the line the cursor is on.  The lower part of the
  121. file is set aside.  The line above the cursor becomes, temporarily, the
  122. bottom of the file; the screen is blank beyond it.  Each blank line you
  123. type on becomes part of the file at that point.
  124.    When the file is open, you can use all the other controls for insertion.
  125. You can page back into the upper part of the file to look at it; you can
  126. delete lines or insert characters.  Control-Z will take you not to the real end
  127. of the file but to the line that was inserted last.
  128.    Once you have inserted as many lines as you want, press control-C.  The
  129. editor splices the file back into a single piece, with the inserted lines
  130. embedded where you typed them.  (This method of insertion is also copied
  131. from the Magic Wand editor.)
  132.  
  133. COMMANDS
  134.    The Stopgap Editor supports just four commands.  Press the "Esc" key.  The
  135. editor clears the screen and displays a menu of the commands.  Pressing the
  136. enter key will return you to the file display.
  137.    The save command asks for a filespec and copies the entire file to disk
  138. under that name.  (If you give it a filespec of "lpt1:", it will copy the 
  139. file to the printer!)  The editor deletes trailing blanks from the end of the
  140. lines saved and discards empty lines at the end of the file.
  141.    The load command asks for a filespec and loads the lines of that file into
  142. storage for editing.  It truncates long lines to the width of the screen
  143. (but doesn't tell you it has done so).  The clear command wipes out everything,
  144. giving you a blank scroll to work on.  The quit command returns you to the 
  145. system.  If you have added or changed anything in the file, these commands
  146. ask for confirmation before they act.
  147.    The Stopgap Editor's disk operations are painfully slow.  It takes a couple
  148. of minutes to load a file of a hundred lines.  If there is any sort of file 
  149. error -  if the disk fills up during a save, for example - you'll get an
  150. error message from Basic.
  151.    Your work hasn't been lost though.  Kill another file to get some space,
  152. then enter the command GOTO 1630.  You should be back in the editor with your
  153. data intact.  But remember, this editor is only a stopgap.  Save your work
  154. often.
  155.  
  156.  
  157.  
  158.         This disk copy was originally provided by "The Public Library",
  159.         the software library of the Houston Area League of PC Users.
  160.         Disks in the Public Libray are updated monthly.  Check with us
  161.         for the latest versions of all programs.
  162.  
  163.         Programs are available from the Public Library at $2 per disk
  164.         on user-provided disks.  To get a listing of the disks in the
  165.         Public Library, send a self-addressed, stamped envelope to
  166.  
  167.              Nelson Ford,  P.O.Box 61565,  Houston, TX 77208.
  168.